AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")

function ENT:Initialize()
	self.Entity:SetModel("models/healthvial.mdl")
	self.Entity:PhysicsInit(SOLID_VPHYSICS)
	self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
	self.Entity:SetSolid(SOLID_VPHYSICS)
	local phys=self.Entity:GetPhysicsObject()
	if phys and phys:IsValid() then phys:Wake() end
	self.damage=10
end

function ENT:OnTakeDamage(dmg)
	self.damage=self.damage-dmg:GetDamage()
	if self.damage<=0 then
		local effectdata=EffectData()
		effectdata:SetOrigin(self.Entity:GetPos())
		effectdata:SetMagnitude(2)
		effectdata:SetScale(2)
		effectdata:SetRadius(3)
		util.Effect("Sparks",effectdata)
		self.Entity:Remove()
	end
end

function ENT:Use(activator,caller)
	if caller:Health()<80 then
		caller:SetHealth(caller:Health()+20)
	elseif caller:Health()==100 then
		return
	else
		caller:SetHealth(100)
	end
	caller:EmitSound("items/smallmedkit1.wav",100,100)
	self.Entity:Remove()
end

function ENT:OnRemove()
end